/*
 *所有关于View_船运收货类的业务代码应在此处编写
*可使用repository.调用常用方法，获取EF/Dapper等信息
*如果需要事务请使用repository.DbContextBeginTransaction
*也可使用DBServerProvider.手动获取数据库相关信息
*用户信息、权限、角色等使用UserContext.Current操作
*View_船运收货Service对增、删、改查、导入、导出、审核业务代码扩展参照ServiceFunFilter
*/
using VOL.Core.BaseProvider;
using VOL.Core.Extensions.AutofacManager;
using VOL.Entity.DomainModels;
using System.Linq;
using VOL.Core.Utilities;
using System.Linq.Expressions;
using VOL.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Http;
using VOL.Wms.IRepositories;
using System.Collections.Generic;
using VOL.Core.Configuration;
using Newtonsoft.Json;
using VOL.Core.ManageUser;
using System;
using VOL.Wms.IRepositories.BaseData;
using VOL.System.IRepositories;
using VOL.Core.DBManager;

namespace VOL.Wms.Services
{
    public partial class View_船运收货Service
    {
        private readonly IHttpContextAccessor _httpContextAccessor;
        private readonly IView_船运收货Repository _repository;//访问数据库
        private readonly IBus_VolumeRepository _volumeRepository;
        private readonly IBus_VolumeScanInRepository _volumeScanInRepository;
        private readonly IBus_StockInVRepository _StockInVRepository;
        private readonly IBus_StockInVolumeRepository _stockInVolumeRepository;
        private readonly IBus_LablePrintRepository _lablePrintRepository;
        private readonly IDic_WarehouseRepository _WarehouseRepository;
        private readonly ISys_CodeRoleRepository _Sys_CodeRoleRepository;
        private readonly ISys_LogRepository _LogRepository;

        [ActivatorUtilitiesConstructor]
        public View_船运收货Service(
            IView_船运收货Repository dbRepository,
            IBus_VolumeRepository bus_VolumeRepository,
            IBus_VolumeScanInRepository volumeScanInRepository,
            IBus_StockInVRepository stockInVRepository,
            IBus_StockInVolumeRepository stockInVolumeRepository,
            IBus_LablePrintRepository lablePrintRepository,
            IDic_WarehouseRepository warehouseRepository,
            ISys_CodeRoleRepository sys_CodeRoleRepository,
            ISys_LogRepository LogRepository,
            IHttpContextAccessor httpContextAccessor
            )
        : base(dbRepository)
        {
            _httpContextAccessor = httpContextAccessor;
            _volumeRepository = bus_VolumeRepository;
            _volumeScanInRepository = volumeScanInRepository;
            _StockInVRepository = stockInVRepository;
            _stockInVolumeRepository = stockInVolumeRepository;
            _lablePrintRepository = lablePrintRepository;
            _WarehouseRepository = warehouseRepository;
            _Sys_CodeRoleRepository = sys_CodeRoleRepository;
            _LogRepository = LogRepository;
            _repository = dbRepository;
            //多租户会用到这init代码，其他情况可以不用
            //base.Init(dbRepository);
        }

        public List<string> queryBoatCode(string queryBoatCode, ref WebResponseContent responseContent)
        {
            List<string> boatCodeList = _repository.Find(it =>
                                                              it.船号.Contains(queryBoatCode)
                                                              && it.收货状态 != AppSetting.GetSection("WorkShopName").Value + "已收货")
                .Select(it => it.船号)
                                                                .ToList();
            return boatCodeList;
        }

        public void queryBoatVolumeCount(View_船运收货 view船运收货, ref WebResponseContent responseContent)
        {
            //string sql = @"select ";
            //from 发岳阳已发货 in _repository.DbContext.Set<View_发岳阳已发货>()
            //where 发岳阳已发货.客户名称 == view发岳阳已发货.客户名称 
            //        && 发岳阳已发货.船号 == view发岳阳已发货.船号
            //        && 发岳阳已发货.卷号

            List<View_船运收货> 发岳阳已发货List = _repository.Find(it => it.客户名称 == view船运收货.客户名称
                                                                 && it.船号 == view船运收货.船号
                                                                 && it.收货状态 != "已收货").ToList();
            if (发岳阳已发货List != null && 发岳阳已发货List.Count > 0)
            {
                responseContent.Code = "0";
                responseContent.Data = 发岳阳已发货List;
            }
            else
            {
                responseContent.Code = "1";
                responseContent.Message = "该船没有待入库的卷";
            }
        }

        public void query船运已发货卷信息(View_船运收货 view船运收货, ref WebResponseContent responseContent)
        {
            VOL.Core.Services.Logger.Info(AppSetting.GetSection("WorkShopName").Value + "码头扫码入库查询卷信息" + JsonConvert.SerializeObject(view船运收货));
            Bus_VolumeScanIn bus_VolumeScanIn = new Bus_VolumeScanIn();
            bus_VolumeScanIn.扫码类型 = AppSetting.GetSection("WorkShopName").Value + "码头扫码入库";
            bus_VolumeScanIn.操作人员 = UserContext.Current.UserName;
            bus_VolumeScanIn.操作时间 = DateTime.Now;
            bus_VolumeScanIn.扫码时间 = DateTime.Now;
            bus_VolumeScanIn.条码 = view船运收货.卷号;
            bus_VolumeScanIn.生产批号 = view船运收货.卷号;
            //塞入扫码记录
            _volumeScanInRepository.Add(bus_VolumeScanIn, true);

            View_船运收货 view_ = _repository.FindFirst(it => it.卷号 == view船运收货.卷号
                                                                                        && it.客户名称 == view船运收货.客户名称);
            if (view_ != null)
            {
                //查询有没有入库过
                Bus_Volume bus_Volume = _volumeRepository.FindFirst(it => it.VolumeCodeNew == view船运收货.卷号);
                if (bus_Volume != null)
                {
                    responseContent.Code = "1";
                    responseContent.Message = "卷号【" + view船运收货.卷号 + "】已经入库，不用再次入库";
                }
                else
                {
                    responseContent.Code = "0";
                    responseContent.Data = view_;
                }
            }
            else
            {
                responseContent.Code = "1";
                responseContent.Message = "未查询到发到"+ AppSetting.GetSection("WorkShopName").Value +"的" +"卷号【" + view船运收货.卷号 + "】信息";
            }
        }

        public async void submitBoatInstorage(View_船运收货 view船运收货, WebResponseContent responseContent)
        {
            VOL.Core.Services.Logger.Info(AppSetting.GetSection("WorkShopName").Value + "扫码入库提交卷信息" + JsonConvert.SerializeObject(view船运收货));
            Bus_VolumeScanIn bus_VolumeScanIn = new Bus_VolumeScanIn();
            bus_VolumeScanIn.扫码类型 = AppSetting.GetSection("WorkShopName").Value + "码头扫码入库";
            bus_VolumeScanIn.操作人员 = UserContext.Current.UserName;
            bus_VolumeScanIn.操作时间 = DateTime.Now;
            bus_VolumeScanIn.扫码时间 = DateTime.Now;
            bus_VolumeScanIn.条码 = view船运收货.卷号;
            bus_VolumeScanIn.生产批号 = view船运收货.卷号;
            //塞入扫码记录
            _volumeScanInRepository.Add(bus_VolumeScanIn, true);

            if (view船运收货 != null && !string.IsNullOrEmpty(view船运收货.卷号))
            {
                //根据卷号重新查询
                View_船运收货 view已发货 = _repository.FindFirst(it => it.卷号 == view船运收货.卷号);
                VOL.Core.Services.Logger.Info(AppSetting.GetSection("WorkShopName").Value+"码头扫码入库根据卷查询到的信息：" + JsonConvert.SerializeObject(view已发货));
                //检查有没有入库了
                Bus_StockInVolume bus_StockInVolume = _stockInVolumeRepository.FindFirst(it => it.VolumeCodeNew == view已发货.卷号);
                if (bus_StockInVolume != null)
                {
                    responseContent.Code = "1";
                    responseContent.Message = "改卷【" + view已发货.卷号 + "】已经入库了，不用再次入库";
                    return;
                }
                //检查有没有在标签库了
                Bus_LablePrint bus_LablePrint = _lablePrintRepository.FindFirst(it => it.生产批号 == view已发货.卷号);
                if (bus_LablePrint != null)
                {
                    responseContent.Code = "1";
                    responseContent.Message = "改卷【" + view已发货.卷号 + "】已经入库了，不用再次入库";
                    return;
                }
                //仓库
                Dic_Warehouse warehouse = _WarehouseRepository.FindFirst(it => it.WarehouseName == view船运收货.仓库名称);
                if (warehouse == null)
                {
                    responseContent.Code = "1";
                    responseContent.Message = "改卷【" + view已发货.卷号 + "】选择的仓库名不存在";
                    return;
                }
                //发送NC
                string 工厂名称 = AppSetting.GetSection("WorkShopName").Value;
                string 仓库名称 = warehouse.WarehouseName;
                string 产线 = "";
                string guid = Guid.NewGuid().ToString();
                string 存货编码 = view已发货.NC存货编号;
                string 批次号 = view已发货.卷号;
                string 重量 = view已发货.重量;
                string 生产日期 = view已发货.ProductDate.GetValueOrDefault().ToString("yyyy-MM-dd ");
                string 品名 = view已发货.InventoryName;
                string 颜色 = view已发货.Color;
                string 长度 = view已发货.Meter.ToString();
                string 产地 = "";
                string 锌层 = view已发货.ZinCeng;
                string 等级 = view已发货.FinishRank;
                string 包装 = view已发货.PackageType;
                string 客户 = "";
                string 表面处理 = view已发货.FaceDone;

                //labelprint 
                Bus_LablePrint lablePrint = new Bus_LablePrint();
                lablePrint.生产批号 = view已发货.卷号;
                lablePrint.guid = Guid.NewGuid();
                lablePrint.来源种类 = "船运";
                lablePrint.来源产线 = "";
                lablePrint.工厂编号 = AppSetting.GetSection("WorkShopCode").Value;
                lablePrint.存货编号 = view已发货.NC存货编号;
                lablePrint.品名 = view已发货.InventoryName;
                lablePrint.钢号 = view已发货.Material;
                lablePrint.条码 = view已发货.卷号;
                //volume里面没有厚度
                lablePrint.厚度 = "";
                产地 = 获取产地(view已发货.发货单行guid, view已发货.卷号);
                if (string.IsNullOrEmpty(产地))
                {
                    lablePrint.产地 = "船运";
                }
                else
                {
                    lablePrint.产地 = 产地;
                }

                lablePrint.长度 = view已发货.Meter.ToString();
                lablePrint.规格 = view已发货.规格;
                lablePrint.等级 = view已发货.FinishRank;
                lablePrint.表面状态 = view已发货.FaceStatus;
                lablePrint.表面处理 = view已发货.FaceDone;
                lablePrint.净重 = view已发货.FinishWeight;
                lablePrint.生产日期 = view已发货.ProductDate;
                lablePrint.仓库 = warehouse.WarehouseCode;
                lablePrint.货位 = view船运收货.StorageLocation;
                lablePrint.锌层 = view已发货.ZinCeng;
                lablePrint.操作人员 = UserContext.Current.UserName;
                lablePrint.操作时间 = DateTime.Now;
                lablePrint.包装形式 = view已发货.PackageType;
                lablePrint.客户 = view已发货.Customer;
                lablePrint.颜色 = view已发货.Color;
                lablePrint.是否已打印 = "否";
                lablePrint.是否抛送NC = "N";
                //塞入大标签表
                //保存信息 抛送成功才保存
                WebResponseContent webResponse = repository.DbContextBeginTransaction(() =>
                {

                    _lablePrintRepository.Add(lablePrint, true);
                    //如果想要回滚，返回new WebResponseContent().Error("返回消息")
                    return new WebResponseContent().OK();
                });
                if (webResponse.Status)
                {
                    responseContent.Message = responseContent.Message + "塞入大标签成功。";
                    //反写收货状态
                    //反写重庆发货单
                    int r = 0;
                    switch (产地)
                    {
                        case "重庆万达":
                            r = 反写船运收货状态("chongqing",view已发货.发货单行guid, view已发货.卷号);
                            break;
                        case "张家港":
                            r = 反写船运收货状态("zhangjiagang", view已发货.发货单行guid, view已发货.卷号);
                            break;
                        case "岳阳攀达":
                            r = 反写船运收货状态("yueyang", view已发货.发货单行guid, view已发货.卷号);
                            break;
                        default:
                            break;
                    }
                    if (r > 0)
                    {
                        responseContent.Message = responseContent.Message + "反写重庆收货状态成功。";
                    }
                    else
                    {
                        responseContent.Message = responseContent.Message + "反写重庆收货状态失败。";
                    }
                }
                else
                {
                    responseContent.Message = responseContent.Message + "塞入数据库失败。";
                }


                #region 暂时不要直接推送NC
                ////busvolume
                //Bus_Volume bus_Volume = new Bus_Volume();
                //bus_Volume.guid = Guid.NewGuid();
                //bus_Volume.WorkShopCode = AppSetting.GetSection("WorkShopCode").Value; 
                //bus_Volume.VolumeCodeNew = view发岳阳已发货.卷号;
                //bus_Volume.FinishSize = view发岳阳已发货.规格;
                //bus_Volume.InventoryCode = view发岳阳已发货.NC存货编号;
                //bus_Volume.InventoryName = view发岳阳已发货.InventoryName;
                //bus_Volume.Material = view发岳阳已发货.Material;
                //bus_Volume.FaceStatus = view发岳阳已发货.FaceStatus;
                //bus_Volume.FaceDone = view发岳阳已发货.FaceDone;
                //bus_Volume.FinishWeight = view发岳阳已发货.FinishWeight;
                //bus_Volume.Meter = view发岳阳已发货.Meter;
                //bus_Volume.FinishRank = view发岳阳已发货.FinishRank;
                //bus_Volume.ProductDate = view发岳阳已发货.ProductDate;
                //bus_Volume.StorageLocation = view发岳阳已发货origen.StorageLocation;
                //bus_Volume.IsInStorage = "在库";
                //bus_Volume.Customer = view发岳阳已发货.Customer;
                //bus_Volume.Address = view发岳阳已发货.Address;
                //bus_Volume.WarehouseCode = warehouse.WarehouseCode;
                //bus_Volume.ZinCeng = view发岳阳已发货.ZinCeng;
                //bus_Volume.PackageType = view发岳阳已发货.PackageType;
                //bus_Volume.Color = view发岳阳已发货.Color;

                ////bus stockinvol
                //Bus_StockInV bus_StockInV = new Bus_StockInV();
                //bus_StockInV.guid = Guid.NewGuid() ;
                //bus_StockInV.StockInType = "产品入库";
                //bus_StockInV.WorkShopCode = AppSetting.GetSection("WorkShopCode").Value;
                //bus_StockInV.DocCode = bus_StockInV.guid.ToString();
                //bus_StockInV.Creator = UserContext.Current.UserName ;
                //bus_StockInV.CreateDate = DateTime.Now ;
                //guid, , , , , , , , 
                //   、, , Thick, Width, , , Weight, CID, Virtual, , , 
                //   , Remark, , , , , , , IsSendToNC, ToNCTime, ToNCJson, 
                //   ToNCResult, WorkLine, PingMing, 

                //Bus_StockInVolume StockInVolume = new Bus_StockInVolume();
                //StockInVolume.guid = bus_Volume.guid;
                //StockInVolume.Bguid = Guid.NewGuid();
                //StockInVolume.CID = "";
                //StockInVolume.DocCode = bus_StockInV.guid.ToString();
                //StockInVolume.RowNumber = 1;
                //StockInVolume.WorkShopCode = AppSetting.GetSection("WorkShopCode").Value;
                //StockInVolume.WarehouseCode = warehouse.WarehouseCode;
                //StockInVolume.WarehouseName = warehouse.WarehouseName; 
                //StockInVolume.StorageLocation = view发岳阳已发货origen.StorageLocation;
                //StockInVolume.VolumeCodeNew = view发岳阳已发货.卷号;
                //StockInVolume.InventoryCode = view发岳阳已发货.NC存货编号;
                //StockInVolume.Size = view发岳阳已发货.FinishSize;
                //StockInVolume.Material = view发岳阳已发货.Material;
                //StockInVolume.Address = view发岳阳已发货.Address;
                //StockInVolume.Weight = view发岳阳已发货.FinishWeight;
                //StockInVolume.FaceStatus = view发岳阳已发货.FaceStatus;
                //StockInVolume.FaceDone = view发岳阳已发货.FaceDone;
                //StockInVolume.NetWeight = view发岳阳已发货.FinishWeight;
                //StockInVolume.ProductDate = view发岳阳已发货.ProductDate;
                //StockInVolume.Grade = view发岳阳已发货.FinishRank;
                //StockInVolume.Meter = view发岳阳已发货.Meter.ToString();
                //StockInVolume.ZinCeng = view发岳阳已发货.ZinCeng;
                //StockInVolume.PackageType = view发岳阳已发货.PackageType;
                //StockInVolume.Customer = view发岳阳已发货.Customer;
                //StockInVolume.PingMing = view发岳阳已发货.InventoryName;
                //StockInVolume.Color = view发岳阳已发货.Color;
                //成功的话写入 入库表和大标签表

                //NCResponseDTO response =  sendToNC产成品(工厂名称, 仓库名称, 产线, guid, 存货编码, 批次号, 重量, 生产日期, 品名, 颜色, 长度, 产地, 锌层, 等级, 包装, 客户, 表面处理).Result ;
                //岳阳 石部长决定 不推NC了，由仓储部核对下再推
                //NCResponseDTO response = new NCResponseDTO();
                //response.state = 1;
                //VOL.Core.Services.Logger.Info(Core.Enums.LoggerType.Success,"","发送NC结果：" + JsonConvert.SerializeObject(response));
                //Sys_Log sys_Log = new Sys_Log();
                //sys_Log.RequestParameter = "发送NC结果：" + JsonConvert.SerializeObject(response);
                //sys_Log.BeginDate = DateTime.Now;
                //sys_Log.EndDate = DateTime.Now;
                //_LogRepository.Add(sys_Log,true);
                //if (response != null && response.state == 0)
                //{
                //    responseContent.Code = "0";
                //    responseContent.Message = "推送NC成功。";
                //    lablePrint.是否抛送NC = "Y";
                //    lablePrint.抛NC结果 = response.result;
                //    lablePrint.抛NC时间 = DateTime.Now;
                //    //反写重庆发货单
                //    DBServerProvider.SetConnection("chongqing", AppSetting.GetSection("Connection:chongqing").Value);
                //    string sql = "update Bus_DeliveryVolume set 收货状态 = @收货状态 , 收货时间 = @收货时间 ,收货人 = @收货人 where bguid = @bguid";
                //   int r = DBServerProvider.GetSqlDapper("chongqing").ExcuteNonQuery(sql, new { 收货状态 = AppSetting.GetSection("WorkShopName").Value+"已收货"
                //                                                                  ,收货时间 = DateTime.Now,收货人 = UserContext.Current.UserName,
                //       bguid = view发岳阳已发货.发货单行guid
                //   });
                //    if (r > 0)
                //    {
                //        responseContent.Message = responseContent.Message + "反写重庆收货状态成功。";
                //    }
                //    else
                //    {
                //        responseContent.Message = responseContent.Message + "反写重庆收货状态失败。";
                //    }
                //    //保存信息 抛送成功才保存
                //    WebResponseContent webResponse = repository.DbContextBeginTransaction(() =>
                //    {

                //        _lablePrintRepository.Add(lablePrint, true);
                //        _StockInVRepository.Add(bus_StockInV, true);
                //        _volumeRepository.Add(bus_Volume, true);
                //        _stockInVolumeRepository.Add(StockInVolume, true);
                //        //如果想要回滚，返回new WebResponseContent().Error("返回消息")
                //        return new WebResponseContent().OK();
                //    });
                //    if (webResponse.Status)
                //    {
                //        responseContent.Message = responseContent.Message + "塞入数据库成功。";
                //    }
                //    else
                //    {
                //        responseContent.Message = responseContent.Message + "塞入数据库失败。";
                //    }
                //}
                //else
                //{
                //    responseContent.Code = "1";
                //    responseContent.Message = response.msg;
                //    lablePrint.是否抛送NC = "N";
                //    lablePrint.抛NC结果 = response.msg;
                //    lablePrint.抛NC时间 = DateTime.Now;
                //}
                ////保存信息 物料有没有跑送成功都保存
                //WebResponseContent webResponse = repository.DbContextBeginTransaction(() =>
                //{

                //    _lablePrintRepository.Add(lablePrint, true);
                //    _StockInVRepository.Add(bus_StockInV, true);
                //    _volumeRepository.Add(bus_Volume, true);
                //    _stockInVolumeRepository.Add(StockInVolume, true);
                //    //如果想要回滚，返回new WebResponseContent().Error("返回消息")
                //    return new WebResponseContent().OK();
                //});
                //if (webResponse.Status)
                //{
                //    responseContent.Message = responseContent.Message+"塞入数据库成功。";
                //}
                //else
                //{
                //    responseContent.Message = responseContent.Message+"塞入数据库失败。";
                //}
                #endregion
            }
            else
            {
                responseContent.Code = "1";
                responseContent.Message = "扫码入库信息不能为空，请检查。";
                return;
            }
        }

        private int 反写船运收货状态(string dbName, Guid deliveryVolumeguid, string 生产批号)
        {
            //反写重庆发货单
            string sql = "update Bus_DeliveryVolume set 收货状态 = @收货状态 , 收货时间 = @收货时间 ,收货人 = @收货人 where bguid = @bguid and VolumeNumber = @VolumeNumber";
            int r = DBServerProvider.GetSqlDapper(dbName).ExcuteNonQuery(sql, new
            {
                收货状态 = AppSetting.GetSection("WorkShopName").Value + "已收货",
                收货时间 = DateTime.Now,
                收货人 = UserContext.Current.UserName,
                bguid = deliveryVolumeguid,
                VolumeNumber = 生产批号
            });
            return r;
        }

        private string 获取产地(Guid deliveryVolumeguid, string 生产批号)
        {
            Bus_DeliveryVolume bus_DeliveryVolume = null;
            string 产地 = "";
            //先加数据库连接
            DBServerProvider.SetConnection("chongqing", AppSetting.GetSection("Connection:chongqing").Value);
            DBServerProvider.SetConnection("yueyang", AppSetting.GetSection("Connection:yueyang").Value);
            DBServerProvider.SetConnection("zhangjiagang", AppSetting.GetSection("Connection:zhangjiagang").Value);

            //当前的工厂名称
            string 工厂编号 = AppSetting.GetSection("WorkShopCode").Value;
            if (工厂编号 == "3001")//岳阳 湖南攀达新型材料有限公司
            {
                //查重庆 和 张家港来的
                bus_DeliveryVolume = queryDeliveryVolume("chongqing", deliveryVolumeguid, 生产批号);
                if (bus_DeliveryVolume != null)
                {
                    产地 = "重庆万达";
                }
                else
                {
                    bus_DeliveryVolume = queryDeliveryVolume("zhangjiagang", deliveryVolumeguid, 生产批号);
                    if (bus_DeliveryVolume != null)
                    {
                        产地 = "张家港";
                    }
                }
            }
            if (工厂编号 == "2001")//重庆 重庆万达薄板有限公司
            {
                //查岳阳 和 张家港来的
                bus_DeliveryVolume = queryDeliveryVolume("yueyang", deliveryVolumeguid, 生产批号);
                if (bus_DeliveryVolume != null)
                {
                    产地 = "岳阳攀达";
                }
                else
                {
                    bus_DeliveryVolume = queryDeliveryVolume("zhangjiagang", deliveryVolumeguid, 生产批号);
                    if (bus_DeliveryVolume != null)
                    {
                        产地 = "张家港";
                    }
                }
            }
            if (工厂编号 == "1001")//张家港 张家港万达薄板有限公司
            {
                //查重庆 和 岳阳来的
                bus_DeliveryVolume = queryDeliveryVolume("chongqing", deliveryVolumeguid, 生产批号);
                if (bus_DeliveryVolume != null)
                {
                    产地 = "重庆万达";
                }
                else
                {
                    bus_DeliveryVolume = queryDeliveryVolume("yueyang", deliveryVolumeguid, 生产批号);
                    if (bus_DeliveryVolume != null)
                    {
                        产地 = "岳阳攀达";
                    }
                }
            }
            return 产地;
        }

        //查询发货单行
        private Bus_DeliveryVolume queryDeliveryVolume(string dbName, Guid deliveryVolumeguid, string 生产批号)
        {
            string sql = "select * from Bus_DeliveryVolume where VolumeNumber = @VolumeNumber and bguid = @bguid";
            Bus_DeliveryVolume bus_DeliveryVolume = DBServerProvider.GetSqlDapper(dbName)
                                    .QueryFirst<Bus_DeliveryVolume>(sql, new { VolumeNumber = 生产批号, bguid = deliveryVolumeguid });
            return bus_DeliveryVolume;
        }
    }
}
